package com.anguin.mylibrary.entity;

import java.sql.Timestamp;
import java.util.Objects;

public class BookEntity extends BaseEntity
{
    private int bookId;          // 书籍ID
    private String title;        // 书籍名称
    private String description;  // 书籍简介
    private String genre;        // 书籍类型
    private int wordCount;       // 书籍字数
    private String author;       // 书籍作者
    private Timestamp publishDate;  // 创作/出版日期
    private String imageUrl;     // 书籍封面图片的URL
    private int status;          // 书籍状态（0表示连载，1表示完结，-1表示下架）
    private float rating;        // 书籍的平均评分
    private int views;           // 点击量/阅读量
    private int userId;          // 用户ID，指向书籍的拥有者


    @Override
    public String toString() {
        return "Book{" +
                "bookId=" + bookId +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", genre='" + genre + '\'' +
                ", wordCount=" + wordCount +
                ", author='" + author + '\'' +
                ", publishDate='" + publishDate + '\'' +
                ", imageUrl='" + imageUrl + '\'' +
                ", status=" + status +
                ", rating=" + rating +
                ", views=" + views +
                ", userId=" + userId +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BookEntity bookEntity = (BookEntity) o;
        return bookId == bookEntity.bookId && wordCount == bookEntity.wordCount && status == bookEntity.status && Float.compare(bookEntity.rating, rating) == 0 && views == bookEntity.views && userId == bookEntity.userId && Objects.equals(title, bookEntity.title) && Objects.equals(description, bookEntity.description) && Objects.equals(genre, bookEntity.genre) && Objects.equals(author, bookEntity.author) && Objects.equals(publishDate, bookEntity.publishDate) && Objects.equals(imageUrl, bookEntity.imageUrl);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bookId, title, description, genre, wordCount, author, publishDate, imageUrl, status, rating, views, userId);
    }

    // 构造函数
    public BookEntity(int bookId, String title, String description, String genre, int wordCount, String author,
                Timestamp publishDate, String imageUrl, int status, float rating, int views, int userId) {
        this.bookId = bookId;
        this.title = title;
        this.description = description;
        this.genre = genre;
        this.wordCount = wordCount;
        this.author = author;
        this.publishDate = publishDate;
        this.imageUrl = imageUrl;
        this.status = status;
        this.rating = rating;
        this.views = views;
        this.userId = userId;
    }
    public BookEntity(){}

    public int getBookId() {
        return bookId;
    }

    public void setBookId(int bookId) {
        this.bookId = bookId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getGenre() {
        return genre;
    }

    public void setGenre(String genre) {
        this.genre = genre;
    }

    public int getWordCount() {
        return wordCount;
    }

    public void setWordCount(int wordCount) {
        this.wordCount = wordCount;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Timestamp getPublishDate() {
        return publishDate;
    }

    public void setPublishDate(Timestamp publishDate) {
        this.publishDate = publishDate;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public float getRating() {
        return rating;
    }

    public void setRating(float rating) {
        this.rating = rating;
    }

    public int getViews() {
        return views;
    }

    public void setViews(int views) {
        this.views = views;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }
}
